package com.icehand.learn.graphql.resolver;

import com.coxautodev.graphql.tools.GraphQLQueryResolver;
import com.icehand.learn.graphql.domain.Author;
import com.icehand.learn.graphql.mapper.AuthorMapper;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.List;

@Slf4j
@Component
@AllArgsConstructor
public class Query implements GraphQLQueryResolver {
	private final AuthorMapper authorMapper;

	public Author findOneAuthor(Long id){
		return authorMapper.selectById(id);
	}

	public List<Author> findAllAuthor(){
		return authorMapper.selectList(null);
	}

	public Long countAuthors(){
		return Long.valueOf(authorMapper.selectCount(null));
	}
}
